﻿package com.badibadi.activity;

import java.util.HashMap;
import java.util.Map;

import com.badibadi.fragment.AfterLandingMyHomePageZhanleiXinFragment;
import com.badibadi.fragment.AfterLandingMyHomePageZhanleiXinFragment.IndexButtonState;
import com.badibadi.fragment.AfterLandingRightSlidingFragment;
import com.badibadi.fragment.AfterLandingMyHomePageClubManangerFragment;
import com.badibadi.fragment.AfterLandingMyHomePageFragment;
import com.badibadi.fragment.AfterLandingMyHomePageChatMessageFragment;
import com.badibadi.fragment.AfterLandingMyHomePageFriendsApplyForFragment;
import com.badibadi.fragment.AfterLandingMyHomePageMessageFragment;
import com.badibadi.fragment.AfterLandingMyHomePageMyFragment;
import com.badibadi.fragment.AfterLandingMyHomePageOtherPeopleFragment;
import com.badibadi.fragment.AfterLandingMyHomePageMyFriendsFragment;
import com.badibadi.fragment.AfterLandingRightSlidingSettingFragment;
import com.badibadi.fragment.WaterFallFragment_1_main;
import com.badibadi.infos.PersonalCenterHomePageModel;
import com.badibadi.infos.Results;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.DisplayUtil;
import com.badibadi.mytools.JPushTools;
import com.badibadi.mytools.MyDiaglogInterface;
import com.badibadi.mytools.MySharePreferences;
import com.badibadi.mytools.MyThreadTool;
import com.badibadi.mytools.Utils;
import com.badibadi.mytools.MyDiaglogInterface.OnMyDiaglogInterClickListener;
import com.badibadi.socket.Send_Geshi_Tool;
import com.badibadi.uniclubber.R;
import com.libjph.util.JsonUtil;

//import com.lidroid.xutils.util.LogUtils;
import com.view.my_view.PaoPao_Button;
import com.view.my_view.SlideMenu;

import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

/**
 * club_ftfd club_activity clubfadongtai 登录后 jiazai club_activity MyShare Utils
 * messageNum l_x xinqingpicture after_landing_index xinqingpicture
 * 
 * <<<<<<< .mine club_daka 请加入俱乐部 123 after_landing_index showTopView
 * 
 * @author Administrator 在这里运行 jiazai onActivty =======
 * @author Administrator 在这里运行 jiazai Options >>>>>>> .r201
 */
public class AfterLandingActivity extends BaseActivity implements
		OnTouchListener, OnClickListener {

	PersonalCenterHomePageModel personalCenterHomePageModel2;
	public static boolean isStartTwoClose = true;// 是否开启点两下回退关闭
	public boolean isStartSocket = false;
	public boolean enterCollect = false;// 进入收藏

	private long exitTime = 0;
	public static AfterLandingActivity instans;// 类似于this
	private SlideMenu slideMenu;
	private Button indexbutton;
	private LinearLayout after_landing_left_layout, ll_layout;
	private Button closedraw_button, before_fanhui;
	private Intent intent = null;
	private FragmentManager myManager = getSupportFragmentManager();
	NotificationManager nm;
	static final int NOTIFICATION_ID = 0x12;
	public boolean isRun = true;// 回调fragment中数据的判断
	// /////特效
	/**
	 * 这里面包括了5个button（未右滑的上面中间两个和下面五个）
	 */
	private ViewPaopaobtn Vp;
	// ////////
	/** 右滑两个fragment（第一个是默认的）（第二个是点击设定按钮后进入的) */
	private AfterLandingRightSlidingFragment afterLandingRightSlidingFragment;
	private AfterLandingRightSlidingSettingFragment afterLandingRightSlidingSettingFragment;
	/**
	 * (两个作废)
	 * 顶部两个按钮按下后的fragment(一个是（好友验证。。@我，申请表，俱乐部联系）)一个是消息的：（配对，创立，赞，评论，分享，收藏，上传）
	 */
	private AfterLandingMyHomePageFriendsApplyForFragment afterLandingMyHomePageFriendsApplyForFragment;
	private AfterLandingMyHomePageMessageFragment afterLandingMyHomePageMessageFragment;
	/**
	 * 这是点击主页看到的自己看到的 (包含很多种动态，如俱乐部，图片上传看到的动态..) (加载项2)
	 */
	private AfterLandingMyHomePageFragment afterLandingMyHomePageAllFragment;

	/** 底部第二个聊天消息的fragment */
	private AfterLandingMyHomePageChatMessageFragment afterLandingMyHomePageChatMessageFragment;
	// private AfterLandingMyHomePagePeiduiFragment
	/** 底部第四个站内信的fragment */
	private AfterLandingMyHomePageZhanleiXinFragment afterLandingMyHomePageZhanleiXinFragment;
	/** 底部第五个好友的fragment */
	private AfterLandingMyHomePageMyFriendsFragment afterLandingMyHomePageMyFriendsFragment;
	/** 评论 7 这是个人的评论(作废) **/
	/** 俱乐部的（管理员）（会员）（和未加入俱乐部的）fragment 8 **/
	private AfterLandingMyHomePageClubManangerFragment afterLandingMyHomePageClubManangerFragment;
	/** 自己的个人中心的fragment 9 **/
	private AfterLandingMyHomePageMyFragment afterLandingMyHomePageMyFragment;
	/** 首页瀑布流 10 **/
	private WaterFallFragment_1_main waterFallFragment;
	/** 11中间的看别人的空间的fragment */
	private AfterLandingMyHomePageOtherPeopleFragment afterLandingMyHomePageOtherPeopleFragment;
	// private
	// /** 详细的的12 只有心情动态才可能会有 **/
	// private AfterLandingXiangXiFragment afterLandingXiangXiFragment;

	/** 点击评论后进入到俱乐部的评论13 **/
	// 多做了一个俱乐部管理的fragment
	// private AfterLandingClubManangerPageFragment
	// afterLandingClubManangerPageFragment;
	/**
	 * 下面两个是悬浮对话框的
	 */
	private View root;
	private PopupWindow popup;
	// boolean PopVisible=false;
	/** 只是为了判定加载的是哪个泡泡按钮 */
	private int add_in = 2;

	private final int INTENT_RESULT = 1;
	private String uid = "1";
	private PersonalCenterHomePageModel personalCenterHomePageModel;
	private Results results1;

	// 这是用于俱乐部主页的(子类来实现的)(用于ClubHomepageActivity)
	/**
	 * //俱乐部id cid; 创建者id c_uid; 这里的创建者id就是管理员的id 当前访问者是否加入该俱乐部 String 0未加入 1加入
	 * is_join;
	 */
	public String cid;
	public String c_uid;
	public String is_join;
	// 俱乐部发动态需要的logo
	protected String logo;
	public static AfterLandingActivity landingActivity;

	private AlertDialog builder;

	Results resultsdd;
	// 消息数量的线程
	Thread messageThread;
	boolean message_isRun = true;
	// public int new_mes_num = 0;
	// 记录id
	// private String OtherId=null;//记录其他人的id,主要用于看别人的动态
	android.os.Handler handler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case 1:
				Utils.ExitPrgress(AfterLandingActivity.this);
				RefreshMessage();
				settingHomePage1Menu();
				infoUser_Blacklist();
				break;
			case 2:
				Utils.ExitPrgress(AfterLandingActivity.this);
				try {
					Utils.showMessage(AfterLandingActivity.this, getResources()
							.getString(R.string.l_net_error));
				} catch (Exception e) {
				}
				break;
			case 3:
				try {
					finish();
				} catch (Exception e) {
				}
				break;
			case 5:
				if (Send_Geshi_Tool.socketThread != null) {
					Send_Geshi_Tool.socketThread.Send(Send_Geshi_Tool
							.fengzhuang_Login(
									Utils.getUid(AfterLandingActivity.this),
									Utils.getPwd(AfterLandingActivity.this)));
				}
				break;
			case 6:
				setPaoPaoButtonMessage(3, "" + Send_Geshi_Tool.new_message_num);
				//
				// + Send_Geshi_Tool.new_message_num);
				break;
			case 7:
				jiazai(9);
				break;
			case 8:
				try {
					Utils.ExitPrgress(AfterLandingActivity.this);
					Utils.showMessage(AfterLandingActivity.this,
							resultsdd.getRetmsg());
					if (resultsdd.isRet() == true) {
						Intent intent = new Intent(AfterLandingActivity.this,
								ClubHomepageActivity.class);
						intent.putExtra("cid", cid);
						startActivity(intent);
						finish();
					}
				} catch (Exception e) {
				}

				break;
			case 9:
				try {
					Utils.ExitPrgress(AfterLandingActivity.this);
					Utils.showMessage(AfterLandingActivity.this, getResources()
							.getString(R.string.l_xa10));
				} catch (Exception e) {
				}

				break;
			case 10:
				try {
					Utils.ExitPrgress(AfterLandingActivity.this);
					Utils.showMessage(AfterLandingActivity.this, getResources()
							.getString(R.string.l_net_error));
				} catch (Exception e) {
				}

				break;
			case 11:// 刷新消息数量的显示
				try {
					RefreshMessage();
				} catch (Exception e) {
				}

				break;
			case 12:
				try {
					Utils.ExitPrgress(AfterLandingActivity.this);
					MySharePreferences preferences = new MySharePreferences(
							AfterLandingActivity.this, "user");
					preferences.put("black_list_id", results1.getRetmsg());
					if (isStartSocket) {
						if (Send_Geshi_Tool.socketThread != null) {
							Send_Geshi_Tool.socketThread
									.Send(Send_Geshi_Tool.fengzhuang_Login(
											Utils.getUid(AfterLandingActivity.this),
											Utils.getPwd(AfterLandingActivity.this)));
						} else {
							Send_Geshi_Tool.startSocket(mhandler, mhandlerSend,
									error_handler, AfterLandingActivity.this);
							handler.sendEmptyMessageDelayed(5, 1000);
						}
					} else {
						//
					}
				} catch (Exception e) {
				}

				break;
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		goToTheTitle();
		// android4Detail();
		uid = Utils.getUid(AfterLandingActivity.this);
		isStartSocket = getIntent().getBooleanExtra("isStartSocket", false);
		isStartTwoClose = getIntent().getBooleanExtra("isStartTwoClose", false);
		landingActivity = this;
		nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
		//
		JPushTools.setJPushInterfaceTuisong(AfterLandingActivity.this, uid);
		// 下面三个参数是俱 乐部主页加上去的
		cid = getIntent().getStringExtra("cid");
		c_uid = getIntent().getStringExtra("c_uid");
		is_join = getIntent().getStringExtra("is_join");
		logo = getIntent().getStringExtra("logo");
		if (!Utils.getUid(AfterLandingActivity.this).equals("")) {
			setContentView(R.layout.after_landing);
			init();
		} else {
			setContentView(R.layout.after_landing_one);
			initone();
		}
		initMessage();// 初始化个人主页的消息
		// init();
		settingRightslidingMenu();

		onlyReshMessage();
		//
		if (Constants.model != null) {
			if (Constants.model.getAmount() != null) {
				if (Integer.parseInt(Constants.model.getAmount()) <= 1) {
					Intent intent = new Intent(AfterLandingActivity.this,
							MyDataActivity.class);
					startActivityForResult(intent, 998);
				} else {
					//
				}
			} else {
				//
			}
		} else {
			//
		}
	}

	@Override
	protected void onStart() {
		super.onStart();
		Constants.Dengchu_handler = handler;
		Constants.New_Mes_handler = handler;
		Send_Geshi_Tool.public_new_mes_num_handler = handler;
		settingRightslidingMenu();
	}

	@Override
	protected void onRestart() {
		super.onRestart();
		message_isRun = true;
		onlyReshMessage();
	}

	/**
	 * 刷新5个泡泡按钮的消息显示
	 */
	private void RefreshMessage() {
		if (personalCenterHomePageModel != null) {
			setPaoPaoButtonMessage(0,
					personalCenterHomePageModel.getClubapply());
			setPaoPaoButtonMessage(1, personalCenterHomePageModel.getMessage());
			// setPaoPaoButtonMessage(0,
			// personalCenterHomePageModel.getClubapply());
			setPaoPaoButtonMessage(5,
					personalCenterHomePageModel.getZhanneiNum());
		}
	};

	/**
	 * 从网上下载消息
	 */
	private void initMessage() {
		Utils.showPrgress(AfterLandingActivity.this);
		new Thread(new Runnable() {
			@Override
			public void run() {
				Map<String, Object> map = new HashMap<String, Object>();
				String t = com.badibadi.mytools.Dialog
						.getSystemLanguageTypegrzx(AfterLandingActivity.this);
				map.put("languageType", t);
				map.put("uid", uid);
				map.put("page", 1);
				map.put("pageNum", 1);
				String content = Utils.sendRequest(map, Constants.BadiUrl
						+ "personal_cente_home_page");
				//
				// + "personal_cente_home_page");
				if (content != null) {
					// ("结果是:" + content);
					Results results = Utils.checkResult_NNN(
							getApplicationContext(), content);
					if (results != null && results.getRetmsg() != null) {
						//
						// ("个人主页返回得到的结果是：    " + content);
						try {
							personalCenterHomePageModel = JsonUtil
									.getEntityByJsonString(results.getRetmsg(),
											PersonalCenterHomePageModel.class);
							//
							// + personalCenterHomePageModel
							// .getUser_trends().size());
						} catch (Exception e) {

						}
						handler.sendEmptyMessage(1);
					}
				} else {
					handler.sendEmptyMessage(2);
				}
			}
		}).start();
	}

	private void infoUser_Blacklist() {
		// Utils.showPrgress(AfterLandingActivity.this);
		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", Utils.getUid(AfterLandingActivity.this));
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "chat/blacklist");
				if (content != null) {
					results1 = Utils.checkResult_NNN(getApplicationContext(),
							content);
					// ("设置界面返回参数是:" + content);
					//
					if (results1 != null && results1.getRetmsg() != null
							&& results1.isRet()) {
						handler.sendEmptyMessage(12);
					} else {
						handler.sendEmptyMessage(9);
					}
				} else {
					handler.sendEmptyMessage(2);
				}
			}
		});
	}

	/**
	 * 只刷新站内信的显示消息(过几秒中刷新一次)
	 */
	public void onlyReshMessage() {
		messageTheadmsg m = new messageTheadmsg();
		messageThread = new Thread(m);
		messageThread.start();
	}

	// on
	@Override
	protected void onPause() {
		super.onPause();
		message_isRun = false;
	}

	class messageTheadmsg implements Runnable {

		@Override
		public void run() {
			while (message_isRun) {
				try {
					Thread.sleep(5000);
				} catch (Exception e) {
				}
				Map<String, Object> map = new HashMap<String, Object>();
				String t = com.badibadi.mytools.Dialog
						.getSystemLanguageTypegrzx(AfterLandingActivity.this);
				map.put("languageType", t);
				map.put("uid", uid);
				map.put("page", 1);
				map.put("pageNum", 1);
				String content = Utils.sendRequest(map, Constants.BadiUrl
						+ "personal_cente_home_page");
				if (content != null) {
					// ("结果是:" + content);
					Results results = Utils.checkResult_NNN(
							getApplicationContext(), content);
					if (results != null && results.getRetmsg() != null) {
						//
						// ("个人主页返回得到的结果是：" + content);
						try {
							personalCenterHomePageModel = JsonUtil
									.getEntityByJsonString(results.getRetmsg(),
											PersonalCenterHomePageModel.class);
							//
						} catch (Exception e) {

						}
						handler.sendEmptyMessage(11);
					}
				} else {
					handler.sendEmptyMessage(2);
				}
			}

		}

	}

	/**
	 * 加载一个悬浮对话框
	 */
	private void settingPopWindows() {
		root = this.getLayoutInflater().inflate(
				R.layout.after_landing_popowindows_import_layout, null);
		root.findViewById(R.id.fadongtai).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent(AfterLandingActivity.this,
								SendDynamicActivity.class);
						intent.putExtra("uid", uid);
						intent.putExtra("head",
								personalCenterHomePageModel.getHead());
						startActivity(intent);
						overridePendingTransition(R.anim.slide_left,
								R.anim.slide_right);
					}
				});
		root.findViewById(R.id.xiejilu).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent(AfterLandingActivity.this,
								AddingRecordNewActivity.class);
						intent.putExtra("uid", uid);
						startActivity(intent);
						overridePendingTransition(R.anim.slide_left,
								R.anim.slide_right);
					}
				});

		float width = getScreenSize(SCREENW);
		int dp80_px = DisplayUtil.dip2px(AfterLandingActivity.this, 80);
		popup = new PopupWindow(root, (int) width, dp80_px);
		popup.setBackgroundDrawable(new BitmapDrawable());
		popup.setFocusable(true);
		popup.setTouchable(true);
		popup.setOutsideTouchable(true);
		popup.showAtLocation(findViewById(R.id.after_landing_bottom_bj3),
				Gravity.BOTTOM, 500,
				DisplayUtil.dip2px(AfterLandingActivity.this, 80));

	}

	/**
	 * 一个Fragment，该Fragment是在左滑后的区域
	 */
	public void settingHomePage1Menu() {
		jiazai(9);
	}

	public void init() {
		instans = this;
		slideMenu = (SlideMenu) findViewById(R.id.slide_menu);
		slideMenu.setAfter(true);
		ll_layout = (LinearLayout) findViewById(R.id.ll_layout);
		afterLandingRightSlidingSettingFragment = new AfterLandingRightSlidingSettingFragment();
		afterLandingRightSlidingFragment = new AfterLandingRightSlidingFragment();

		afterLandingMyHomePageMessageFragment = new AfterLandingMyHomePageMessageFragment();
		afterLandingMyHomePageZhanleiXinFragment = new AfterLandingMyHomePageZhanleiXinFragment();

		Bundle bu1 = new Bundle();
		bu1.putFloat("SCREENW", getScreenSize(SCREENW));
		afterLandingMyHomePageMessageFragment.setArguments(bu1);

		afterLandingMyHomePageFriendsApplyForFragment = new AfterLandingMyHomePageFriendsApplyForFragment();
		afterLandingMyHomePageOtherPeopleFragment = new AfterLandingMyHomePageOtherPeopleFragment();

		afterLandingMyHomePageMyFriendsFragment = new AfterLandingMyHomePageMyFriendsFragment();
		afterLandingMyHomePageAllFragment = new AfterLandingMyHomePageFragment();

		afterLandingMyHomePageChatMessageFragment = new AfterLandingMyHomePageChatMessageFragment();

		afterLandingMyHomePageClubManangerFragment = new AfterLandingMyHomePageClubManangerFragment();
		afterLandingMyHomePageMyFragment = new AfterLandingMyHomePageMyFragment();

		Vp = new ViewPaopaobtn();

		Vp.mPapapTop_btn1 = (PaoPao_Button) findViewById(R.id.after_landing_top_paoPaobtn1);
		Vp.mPapapTop_btn1.setBottomBackgroundResource(Vp.Top_pic[0]);
		Vp.mPapapTop_btn2 = (PaoPao_Button) findViewById(R.id.after_landing_top_paoPaobtn2);
		Vp.mPapapTop_btn2.setBottomBackgroundResource(Vp.Top_pic[1]);
		Vp.mPaoPaoBottom_btn1 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn1);
		Vp.mPaoPaoBottom_btn2 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn2);
		Vp.mPaoPaoBottom_btn3 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn3);
		Vp.mPaoPaoBottom_btn4 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn4);
		Vp.mPaoPaoBottom_btn5 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn5);

		Vp.mPaoPaoBottombg1 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj1);
		Vp.mPaoPaoBottombg2 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj2);
		Vp.mPaoPaoBottombg3 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj3);
		Vp.mPaoPaoBottombg4 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj4);
		Vp.mPaoPaoBottombg5 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj5);
		// 四个文本
		Vp.mPaoPaoBottom_tv1 = (TextView) findViewById(R.id.after_landing_botton_text1);
		Vp.mPaoPaoBottom_tv2 = (TextView) findViewById(R.id.after_landing_botton_text2);
		Vp.mPaoPaoBottom_tv4 = (TextView) findViewById(R.id.after_landing_botton_text4);
		Vp.mPaoPaoBottom_tv5 = (TextView) findViewById(R.id.after_landing_botton_text5);
		// 初始化中间的图片
		Vp.mPaoPaoBottom_btn1.setBottomBackgroundResource(Vp.Bottom_pic[0]);
		Vp.mPaoPaoBottom_btn2.setBottomBackgroundResource(Vp.Bottom_pic[1]);
		Vp.mPaoPaoBottom_btn3.setBottomBackgroundResource(Vp.Bottom_pic[2]);
		Vp.mPaoPaoBottom_btn4.setBottomBackgroundResource(Vp.Bottom_pic[3]);
		Vp.mPaoPaoBottom_btn5.setBottomBackgroundResource(Vp.Bottom_pic[4]);
		Vp.mPapapTop_btn1.setOnTouchListener(this);
		Vp.mPapapTop_btn2.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn1.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn2.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn3.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn4.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn5.setOnTouchListener(this);

		indexbutton = (Button) findViewById(R.id.after_landing_index);
		indexbutton.setOnClickListener(AfterLandingActivity.this);
		closedraw_button = (Button) findViewById(R.id.after_landing_closedraw_button);
		closedraw_button.setOnClickListener(AfterLandingActivity.this);

	};

	public void initone() {
		instans = this;
		slideMenu = (SlideMenu) findViewById(R.id.slide_menu);
		slideMenu.setAfter(true);
		ll_layout = (LinearLayout) findViewById(R.id.ll_layout);
		afterLandingRightSlidingSettingFragment = new AfterLandingRightSlidingSettingFragment();
		afterLandingRightSlidingFragment = new AfterLandingRightSlidingFragment();

		afterLandingMyHomePageMessageFragment = new AfterLandingMyHomePageMessageFragment();
		afterLandingMyHomePageZhanleiXinFragment = new AfterLandingMyHomePageZhanleiXinFragment();

		Bundle bu1 = new Bundle();
		bu1.putFloat("SCREENW", getScreenSize(SCREENW));
		afterLandingMyHomePageMessageFragment.setArguments(bu1);

		afterLandingMyHomePageFriendsApplyForFragment = new AfterLandingMyHomePageFriendsApplyForFragment();
		afterLandingMyHomePageOtherPeopleFragment = new AfterLandingMyHomePageOtherPeopleFragment();

		afterLandingMyHomePageMyFriendsFragment = new AfterLandingMyHomePageMyFriendsFragment();
		afterLandingMyHomePageAllFragment = new AfterLandingMyHomePageFragment();

		afterLandingMyHomePageChatMessageFragment = new AfterLandingMyHomePageChatMessageFragment();

		afterLandingMyHomePageClubManangerFragment = new AfterLandingMyHomePageClubManangerFragment();
		afterLandingMyHomePageMyFragment = new AfterLandingMyHomePageMyFragment();

		Vp = new ViewPaopaobtn();

		Vp.mPapapTop_btn1 = (PaoPao_Button) findViewById(R.id.after_landing_top_paoPaobtn1);
		Vp.mPapapTop_btn1.setBottomBackgroundResource(Vp.Top_pic[0]);
		Vp.mPapapTop_btn2 = (PaoPao_Button) findViewById(R.id.after_landing_top_paoPaobtn2);
		Vp.mPapapTop_btn2.setBottomBackgroundResource(Vp.Top_pic[1]);
		Vp.mPaoPaoBottom_btn1 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn1);
		Vp.mPaoPaoBottom_btn2 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn2);
		Vp.mPaoPaoBottom_btn3 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn3);
		Vp.mPaoPaoBottom_btn4 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn4);
		Vp.mPaoPaoBottom_btn5 = (PaoPao_Button) findViewById(R.id.after_landing_bottom_paoPaobtn5);

		Vp.mPaoPaoBottombg1 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj1);
		Vp.mPaoPaoBottombg2 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj2);
		Vp.mPaoPaoBottombg3 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj3);
		Vp.mPaoPaoBottombg4 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj4);
		Vp.mPaoPaoBottombg5 = (LinearLayout) findViewById(R.id.after_landing_bottom_bj5);
		// 四个文本
		Vp.mPaoPaoBottom_tv1 = (TextView) findViewById(R.id.after_landing_botton_text1);
		Vp.mPaoPaoBottom_tv2 = (TextView) findViewById(R.id.after_landing_botton_text2);
		Vp.mPaoPaoBottom_tv4 = (TextView) findViewById(R.id.after_landing_botton_text4);
		Vp.mPaoPaoBottom_tv5 = (TextView) findViewById(R.id.after_landing_botton_text5);
		// 初始化中间的图片
		Vp.mPaoPaoBottom_btn1.setBottomBackgroundResource(Vp.Bottom_pic[0]);
		Vp.mPaoPaoBottom_btn2.setBottomBackgroundResource(Vp.Bottom_pic[1]);
		Vp.mPaoPaoBottom_btn3.setBottomBackgroundResource(Vp.Bottom_pic[2]);
		Vp.mPaoPaoBottom_btn4.setBottomBackgroundResource(Vp.Bottom_pic[3]);
		Vp.mPaoPaoBottom_btn5.setBottomBackgroundResource(Vp.Bottom_pic[4]);
		Vp.mPapapTop_btn1.setOnTouchListener(this);
		Vp.mPapapTop_btn2.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn1.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn2.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn3.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn4.setOnTouchListener(this);
		Vp.mPaoPaoBottom_btn5.setOnTouchListener(this);

		indexbutton = (Button) findViewById(R.id.after_landing_index);
		indexbutton.setOnClickListener(AfterLandingActivity.this);

		before_fanhui = (Button) findViewById(R.id.before_fanhui);
		before_fanhui.setOnClickListener(AfterLandingActivity.this);
	};

	@Override
	protected void onDestroy() {
		super.onDestroy();
		if (isStartSocket) {
			Send_Geshi_Tool.stopSocket();
		} else {
		}
	}

	@Override
	public boolean onTouch(View view, MotionEvent event) {

		switch (view.getId()) {
		case R.id.after_landing_top_paoPaobtn1:
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				Vp.mPapapTop_btn1
						.setBottomBackgroundResource(Vp.Top_pic_select[0]);
				BottomPaoPaoButtonReset();
			}
			if (event.getAction() == MotionEvent.ACTION_UP) {
				Vp.mPapapTop_btn1.setBottomBackgroundResource(Vp.Top_pic[0]);
				// // 泡泡不可见
				// Vp.mPapapTop_btn1.setPaoPaoInVisible();
				setClickButton(R.id.after_landing_top_paoPaobtn1);
			}
			break;

		case R.id.after_landing_top_paoPaobtn2:
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				Vp.mPapapTop_btn2
						.setBottomBackgroundResource(Vp.Top_pic_select[1]);
				BottomPaoPaoButtonReset();
			}
			if (event.getAction() == MotionEvent.ACTION_UP) {
				Vp.mPapapTop_btn2.setBottomBackgroundResource(Vp.Top_pic[1]);
				// 泡泡不可见
				// Vp.mPapapTop_btn2.setPaoPaoInVisible();
				setClickButton(R.id.after_landing_top_paoPaobtn2);
			}
			break;
		// 下面的是底部的
		// 首页
		case R.id.after_landing_bottom_paoPaobtn1: {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				if (Vp.BottomButtonSelect != 0) {
					Vp.mPaoPaoBottom_btn1.setPaoPaoInVisible();
					Vp.BottomButtonSelect = 0;
				}
				BottomPaoPaoButtonReset();
				setClickButton(R.id.after_landing_bottom_paoPaobtn1);
				// setPopVisible(false);
			}
		}
			break;
		// 聊天
		case R.id.after_landing_bottom_paoPaobtn2: {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				if (Vp.BottomButtonSelect != 1) {
					Vp.mPaoPaoBottom_btn2.setPaoPaoInVisible();
					Vp.BottomButtonSelect = 1;
				}
				BottomPaoPaoButtonReset();
				setClickButton(R.id.after_landing_bottom_paoPaobtn2);
			}

		}
			break;
		// 中间的按钮
		case R.id.after_landing_bottom_paoPaobtn3: {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				if (Vp.BottomCenterButtonSelect == false) {
					// Vp.BottomCenterButtonSelect=true;
					Vp.mPaoPaoBottom_btn3
							.setBottomBackgroundResource(Vp.Bottom_pic_select[2]);
					setClickButton(R.id.after_landing_bottom_paoPaobtn3);
				}
				// else if(Vp.BottomCenterButtonSelect==true)
				// {
				// Vp.BottomCenterButtonSelect=false;
				// Vp.mPaoPaoBottom_btn3.setBottomBackgroundResource(Vp.Bottom_pic[2]);
				// setClickButton(R.id.after_landing_bottom_paoPaobtn3);
				// }
			}
			if (event.getAction() == MotionEvent.ACTION_UP) {
				Vp.mPaoPaoBottom_btn3
						.setBottomBackgroundResource(Vp.Bottom_pic[2]);
			}
		}
			break;
		// 站内信
		case R.id.after_landing_bottom_paoPaobtn4: {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				if (Vp.BottomButtonSelect != 3) {
					// Vp.mPaoPaoBottom_btn4.setPaoPaoInVisible();
					Vp.BottomButtonSelect = 3;
				}
				BottomPaoPaoButtonReset();
				setClickButton(R.id.after_landing_bottom_paoPaobtn4);
			}
		}
			break;
		// 聊天
		case R.id.after_landing_bottom_paoPaobtn5: {

			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				if (Vp.BottomButtonSelect != 4) {
					Vp.mPaoPaoBottom_btn5.setPaoPaoInVisible();
					Vp.BottomButtonSelect = 4;
				}
				BottomPaoPaoButtonReset();
				setClickButton(R.id.after_landing_bottom_paoPaobtn5);
			}
		}
			break;
		}

		return true;
	}

	/**
	 * 刷新底部所有按钮中间图片和背景和字体 能够初始化popwindows
	 * 
	 */
	public void BottomPaoPaoButtonReset() {
		switch (Vp.BottomButtonSelect) {
		case 0:
			// 首页
			Vp.mPaoPaoBottom_btn1
					.setBottomBackgroundResource(Vp.Bottom_pic_select[0]);
			Vp.mPaoPaoBottom_btn2.setBottomBackgroundResource(Vp.Bottom_pic[1]);
			Vp.mPaoPaoBottom_btn3.setBottomBackgroundResource(Vp.Bottom_pic[2]);
			Vp.mPaoPaoBottom_btn4.setBottomBackgroundResource(Vp.Bottom_pic[3]);
			Vp.mPaoPaoBottom_btn5.setBottomBackgroundResource(Vp.Bottom_pic[4]);
			Vp.mPaoPaoBottombg1.setBackgroundResource(Vp.Button_beijing[0]);
			Vp.mPaoPaoBottombg2.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg3.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg4.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg5.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottom_tv1.setTextColor(getResources().getColor(
					R.color.blue));
			Vp.mPaoPaoBottom_tv2.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv4.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv5.setTextColor(Color.WHITE);
			Vp.BottomCenterButtonSelect = false;
			break;
		case 1:
			// 聊天
			Vp.mPaoPaoBottom_btn1.setBottomBackgroundResource(Vp.Bottom_pic[0]);
			Vp.mPaoPaoBottom_btn2
					.setBottomBackgroundResource(Vp.Bottom_pic_select[1]);
			Vp.mPaoPaoBottom_btn3.setBottomBackgroundResource(Vp.Bottom_pic[2]);
			Vp.mPaoPaoBottom_btn4.setBottomBackgroundResource(Vp.Bottom_pic[3]);
			Vp.mPaoPaoBottom_btn5.setBottomBackgroundResource(Vp.Bottom_pic[4]);
			Vp.mPaoPaoBottombg1.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg2.setBackgroundResource(Vp.Button_beijing[0]);
			Vp.mPaoPaoBottombg3.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg4.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg5.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottom_tv1.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv2.setTextColor(getResources().getColor(
					R.color.blue));
			Vp.mPaoPaoBottom_tv4.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv5.setTextColor(Color.WHITE);
			Vp.BottomCenterButtonSelect = false;
			break;
		case 2:
			break;
		case 3:
			// 站内信
			Vp.mPaoPaoBottom_btn1.setBottomBackgroundResource(Vp.Bottom_pic[0]);
			Vp.mPaoPaoBottom_btn2.setBottomBackgroundResource(Vp.Bottom_pic[1]);
			Vp.mPaoPaoBottom_btn3.setBottomBackgroundResource(Vp.Bottom_pic[2]);
			Vp.mPaoPaoBottom_btn4
					.setBottomBackgroundResource(Vp.Bottom_pic_select[3]);
			Vp.mPaoPaoBottom_btn5.setBottomBackgroundResource(Vp.Bottom_pic[4]);
			Vp.mPaoPaoBottombg1.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg2.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg3.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg4.setBackgroundResource(Vp.Button_beijing[0]);
			Vp.mPaoPaoBottombg5.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottom_tv1.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv2.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv4.setTextColor(getResources().getColor(
					R.color.blue));
			Vp.mPaoPaoBottom_tv5.setTextColor(Color.WHITE);
			Vp.BottomCenterButtonSelect = false;
			break;
		case 4:
			// 聊天
			Vp.mPaoPaoBottom_btn1.setBottomBackgroundResource(Vp.Bottom_pic[0]);
			Vp.mPaoPaoBottom_btn2.setBottomBackgroundResource(Vp.Bottom_pic[1]);
			Vp.mPaoPaoBottom_btn3.setBottomBackgroundResource(Vp.Bottom_pic[2]);
			Vp.mPaoPaoBottom_btn4.setBottomBackgroundResource(Vp.Bottom_pic[3]);
			Vp.mPaoPaoBottom_btn5
					.setBottomBackgroundResource(Vp.Bottom_pic_select[4]);
			Vp.mPaoPaoBottombg1.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg2.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg3.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg4.setBackgroundResource(Vp.Button_beijing[1]);
			Vp.mPaoPaoBottombg5.setBackgroundResource(Vp.Button_beijing[0]);
			Vp.mPaoPaoBottom_tv1.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv2.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv4.setTextColor(Color.WHITE);
			Vp.mPaoPaoBottom_tv5.setTextColor(getResources().getColor(
					R.color.blue));
			Vp.BottomCenterButtonSelect = false;
			break;

		}
		// setPopVisible(false);
	}

	/**
	 * sd 初始化左侧菜单(还原到默认) （右滑菜单）
	 */
	public void settingRightslidingMenu() {
		after_landing_left_layout = (LinearLayout) findViewById(R.id.after_landing_left_layout);
		FragmentManager manager = getSupportFragmentManager();
		FragmentTransaction transaction = manager.beginTransaction();
		afterLandingRightSlidingFragment = new AfterLandingRightSlidingFragment();
		// AfterLandingRightSlidingFragment
		// .getInstance();

		transaction.replace(R.id.after_landing_left_layout,
				afterLandingRightSlidingFragment);
		transaction.commit();
	}

	/**
	 * 通知左侧菜单更换为设定信息
	 */
	public void setOnChangeToSettingFragment() {
		ViewFragmentHolder viewHolder = new ViewFragmentHolder();
		viewHolder.manager = getSupportFragmentManager();
		viewHolder.transaction = viewHolder.manager.beginTransaction();
		viewHolder.transaction.replace(R.id.after_landing_left_layout,
				afterLandingRightSlidingSettingFragment,
				"afterLandingRightSlidingSettingFragment");
		// viewHolder.transaction.addToBackStack("afterLandingRightSlidingSettingFragment");
		viewHolder.transaction.commit();

	}

	/**
	 * 把五个泡泡按钮的点击事件放在这处理（根据id）
	 * 
	 * @param id
	 */
	private void setClickButton(int id) {
		switch (id) {
		case R.id.after_landing_top_paoPaobtn1:
			// 创建一个启动其他Activity的Intent
//			Intent intent = new Intent(AfterLandingActivity.this,
//					ClubListActivity.class);
//			PendingIntent pi = PendingIntent.getActivity(
//					AfterLandingActivity.this, 0, intent, 0);
//			Notification notify = new Notification.Builder(this)
//			// 设置打开该通知，该通知自动消失
//					.setAutoCancel(true)
//					// 设置显示在状态栏的通知提示信息
//					.setTicker("有新消息")
//					// 设置通知的图标
//					.setSmallIcon(R.drawable.ic_launcher)
//					// 设置通知内容的标题
//					.setContentTitle("一条新通知")
//					// 设置通知内容
//					.setContentText("恭喜你，您加薪了，工资增加20%!")
//					// Notification.DEFAULT_SOUND设置默认声音。
//					// Notification.DEFAULT_VIBRATE设置默认振动。
//					// Notification.DEFAULT_LIGHTS设置默认闪光灯
//					// Notification.DEFAULT_ALL设置使用系统默认的声音、默认LED灯，振动。
//					// .setDefaults(Notification.DEFAULT_SOUND
//					// |Notification.DEFAULT_LIGHTS)
//					// 设置通知的自定义声音
//
//					// 设置自定义声音
//					// .setSound(Uri.parse("file:///sdcard/click.mp3"))
//					// 设置自定义振动
//					// .setVibrate(new long[] { 0, 50, 100, 150 })
//					.setWhen(System.currentTimeMillis())
//					// 设改通知将要启动程序的Intent
//					.setContentIntent(pi).build();
//			// 发送通知
//			nm.notify(NOTIFICATION_ID, notify);
			jiazai(0);
			break;
		case R.id.after_landing_top_paoPaobtn2:
			jiazai(1);
			break;
		case R.id.after_landing_bottom_paoPaobtn1:

			jiazai(2);
			break;
		case R.id.after_landing_bottom_paoPaobtn2:
			jiazai(3);
			break;
		case R.id.after_landing_bottom_paoPaobtn3:
			settingPopWindows();
			break;
		case R.id.after_landing_bottom_paoPaobtn4:
			jiazai(5);
			break;
		case R.id.after_landing_bottom_paoPaobtn5:
			jiazai(6);
			break;
		}

	}

	/**
	 * 根据num 加载 fragment (注意：所有7个泡泡按钮中只有6个有 0,1 ,2,3, 5,6,) 7是评论，（上一级fragment为）
	 * 
	 * @param num
	 *            0
	 */
	public void jiazai(int num) {

		// System.out.println("num=" +num);//查看初始num值 結果是9
		if (num == 0) {// 邀请通知

			if (personalCenterHomePageModel != null) {
				intent = new Intent(AfterLandingActivity.this,
						InvitationsActivity.class);
				intent.putExtra("uid", uid);
				intent.putExtra("messageNum",
						personalCenterHomePageModel.getClubapply());
				startActivity(intent);
				overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
			}

			return;

		} else if (num == 1) {// 消息通知
			if (personalCenterHomePageModel != null) {
				intent = new Intent(AfterLandingActivity.this,
						NoticeActivity.class);
				intent.putExtra("uid", uid);
				intent.putExtra("messageNum",
						personalCenterHomePageModel.getMessage());
				startActivity(intent);
				overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
			}
			return;
		}

		FragmentTransaction myTransaction = myManager.beginTransaction();
		if (num == 8)// 俱乐部的clubfadongtai
		{
			this.findViewById(R.id.club_ftfd).setVisibility(View.VISIBLE);
			this.findViewById(R.id.bottom_tabhost).setVisibility(View.GONE);
			club_options();
		} else {
			this.findViewById(R.id.club_ftfd).setVisibility(View.GONE);
			this.findViewById(R.id.bottom_tabhost).setVisibility(View.VISIBLE);
		}

		if (num == 5) {
			ShowRubbishButton();
		} else {
			ShowIndexButton();
		}

		if (num == 6) {
			indexbutton.setSelected(true);
		} else {
			indexbutton.setSelected(false);
		}
		if (add_in != 2 && num == 2) {// 所有动态
			afterLandingMyHomePageAllFragment = new AfterLandingMyHomePageFragment();
			myTransaction.replace(R.id.after_landing_layout,
					afterLandingMyHomePageAllFragment);

			myTransaction.commit();
			add_in = 2;
		} else if (add_in != 3 && num == 3) {// 聊天消息
			// new_message_num = 0;
			afterLandingMyHomePageChatMessageFragment = new AfterLandingMyHomePageChatMessageFragment();
			myTransaction.replace(R.id.after_landing_layout,
					afterLandingMyHomePageChatMessageFragment);
			myTransaction.commit();
			add_in = 3;
		} else if (add_in != 5 && num == 5) {// 底部站内信的
			afterLandingMyHomePageZhanleiXinFragment = new AfterLandingMyHomePageZhanleiXinFragment();
			myTransaction.replace(R.id.after_landing_layout,
					afterLandingMyHomePageZhanleiXinFragment);
			myTransaction.commit();
			add_in = 5;
		} else if (add_in != 6 && num == 6) {
			afterLandingMyHomePageMyFriendsFragment = new AfterLandingMyHomePageMyFriendsFragment();
			myTransaction.replace(R.id.after_landing_layout,
					afterLandingMyHomePageMyFriendsFragment);
			myTransaction.commit();
			add_in = 6;

		} else if (add_in != 7 && num == 7) {
			isStartTwoClose = false;
			myTransaction
					.addToBackStack("afterLandingMyHomePagePingLunFragment");
			myTransaction.commit();
		} else if (add_in != 8 && num == 8) {// 俱乐部的个人主页
			afterLandingMyHomePageClubManangerFragment = new AfterLandingMyHomePageClubManangerFragment();
			Bundle bun = new Bundle();
			bun.putString("cid", cid);
			bun.putString("c_uid", c_uid);
			bun.putString("is_join", is_join);
			afterLandingMyHomePageClubManangerFragment.setArguments(bun);
			myTransaction.replace(R.id.after_landing_layout,
					afterLandingMyHomePageClubManangerFragment);
			myTransaction.commit();
			add_in = 8;
		} else if (add_in != 9 && num == 9) {

			afterLandingMyHomePageMyFragment = AfterLandingMyHomePageMyFragment
					.getInstance();
			Bundle bun = new Bundle();
			bun.putBoolean("enterCollect", enterCollect);
			afterLandingMyHomePageMyFragment.setArguments(bun);
			myTransaction.replace(R.id.after_landing_layout,
					afterLandingMyHomePageMyFragment);
			myTransaction.commit();
			add_in = 9;
			enterCollect = false;
		} else if (add_in != 10 && num == 10) {
			waterFallFragment = new WaterFallFragment_1_main();
			myTransaction.replace(R.id.after_landing_layout, waterFallFragment);
			myTransaction.commit();
			add_in = 10;
		} else if (add_in != 11 && num == 11) {// 这是看其他人的
			afterLandingMyHomePageOtherPeopleFragment = new AfterLandingMyHomePageOtherPeopleFragment();
			Bundle bun = new Bundle();
			bun.putString("fid", uid);
			myTransaction.replace(R.id.after_landing_layout,
					afterLandingMyHomePageOtherPeopleFragment,
					"afterLandingMyHomePageOtherPeopleFragment");
			myTransaction.commit();
		} else if (add_in != 12 && num == 12)// 评论的Fragment
		{
		} else if (add_in != 13 && num == 13) {// 俱乐部的评论
			isStartTwoClose = false;
			myTransaction
					.addToBackStack("afterLandingMyHomePagePingLunClubFragment");
			myTransaction.commit();
		}

	}

	private void ShowIndexButton() {
		indexbutton
				.setBackgroundResource(R.drawable.selector_index_and_setting);
	}

	/**
	 * 显示右上角的垃圾回收按钮
	 */
	public void ShowRubbishButton() {
		indexbutton.setBackgroundResource(R.drawable.btn_rubbish);
	}

	/**
	 * 初始化的五个按钮
	 * 
	 * @author Administrator
	 * 
	 */
	public class ViewPaopaobtn {
		/**
		 * 两个顶部的泡泡按钮
		 */
		PaoPao_Button mPapapTop_btn1, mPapapTop_btn2;
		/** 五个底部的泡泡按钮 */
		PaoPao_Button mPaoPaoBottom_btn1, mPaoPaoBottom_btn2,
				mPaoPaoBottom_btn3, mPaoPaoBottom_btn4, mPaoPaoBottom_btn5;
		/** 四个底部Text(没有3) */
		TextView mPaoPaoBottom_tv1, mPaoPaoBottom_tv2, mPaoPaoBottom_tv4,
				mPaoPaoBottom_tv5;
		/** 对应着5个底部泡泡背景(包含中间的) */
		LinearLayout mPaoPaoBottombg1, mPaoPaoBottombg2, mPaoPaoBottombg3,
				mPaoPaoBottombg4, mPaoPaoBottombg5;
		/** 这里全是带泡泡的图片 */
		int[] Top_pic = { R.drawable.after_landing_title1,
				R.drawable.after_landing_title2 };
		int[] Top_pic_select = { R.drawable.after_landing_title1_select,
				R.drawable.after_landing_title2_select };
		int[] Bottom_pic = { R.drawable.home, R.drawable.talk,
				R.drawable.menu1, R.drawable.email, R.drawable.friend };
		int[] Bottom_pic_select = { R.drawable.home_select,
				R.drawable.talk_select, R.drawable.menu1_select,
				R.drawable.email_select, R.drawable.friend_select };
		int[] Button_beijing = { R.drawable.white_f, R.drawable.blue_00a2d0 };

		/**
		 * 用于判断点击的是底部几个，第三个不起作用（也就是BottomButtonSelect不会等于2）
		 * 底部按钮初始显示的是主页.（BottomButtonSelect控制底部点击的是哪一个，一共5个）
		 * 0代表当前点击的是主页，1聊天，2不起作用，3站内信，4朋友
		 */
		int BottomButtonSelect = -1;
		/**
		 * 中间的是否按下
		 */
		boolean BottomCenterButtonSelect = false;

	}

	/**
	 * 设置PaoPao按钮的消息
	 * 
	 * @param num
	 *            0 1 是上面两个 下面四个是 2、3、5、6
	 * @param MessageNum
	 */
	public void setPaoPaoButtonMessage(int num, String MessageNum) {

		if (MessageNum != null) {
			if (num == 0) {
				Vp.mPapapTop_btn1.setMessage(MessageNum);
			} else if (num == 1) {
				Vp.mPapapTop_btn2.setMessage(MessageNum);
			} else if (num == 2) {
				Vp.mPaoPaoBottom_btn1.setMessage(MessageNum);
			} else if (num == 3) {
				Vp.mPaoPaoBottom_btn2.setMessage(MessageNum);
			} else if (num == 5) {
				Vp.mPaoPaoBottom_btn4.setMessage(MessageNum);
			} else if (num == 6) {
				Vp.mPaoPaoBottom_btn5.setMessage(MessageNum);
			}
		}

	}

	@Override
	public void onClick(View v) {
		if (!Utils.getUid(AfterLandingActivity.this).equals("")) {

			/*
			 * before_fanhui.setVisibility(View.GONE);
			 * closedraw_button.setVisibility(View.VISIBLE);
			 */
			switch (v.getId()) {
			case R.id.after_landing_index:
				if (add_in == 5) {
					if (indexbutton.isSelected() == true) {
						indexbutton.setSelected(false);
						afterLandingMyHomePageZhanleiXinFragment
								.setOnIndexClistener(new IndexButtonState() {
									@Override
									public boolean indexButtonSelect(
											boolean isSelectIndexBtn) {
										return isSelectIndexBtn = false;
									}
								});
					} else {
						indexbutton.setSelected(true);

						afterLandingMyHomePageZhanleiXinFragment
								.setOnIndexClistener(new IndexButtonState() {

									@Override
									public boolean indexButtonSelect(
											boolean isSelectIndexBtn) {
										return true;
									}
								});
						// 更新适配器

					}

				} else if (indexbutton.isSelected() == false) {
					intent = new Intent(AfterLandingActivity.this,
							IndexActivity.class);
				} else if (indexbutton.isSelected() == true) {
					String[] items = new String[] {
							getResources().getString(R.string.TheEditor),
							getResources().getString(R.string.Add) };
					MyDiaglogInterface d = new MyDiaglogInterface(
							AfterLandingActivity.this);
					d.singleChoice(items);
					d.setOnMyDiaglogInterClickListener(new OnMyDiaglogInterClickListener() {

						@Override
						public void ok(int itemNum) {
							if (itemNum == 0) {
								intent = new Intent(AfterLandingActivity.this,
										GroupManagementActivity.class);

							} else if (itemNum == 1) {
								intent = new Intent(AfterLandingActivity.this,
										AddFriendsActivity.class);
							}
							if (intent != null) {
								startActivity(intent);
								intent = null;
							}
						}

						@Override
						public void cancle(int itemNum) {
						}
					});

				}
				break;
			case R.id.after_landing_closedraw_button:
				if (slideMenu.isMainScreenShowing()) {
					slideMenu.openMenu();
					settingRightslidingMenu();
				} else {
					slideMenu.closeMenu();
				}
				break;

			}
			if (intent != null) {
				startActivity(intent);
				intent = null;
			}

		} else {
			/*
			 * closedraw_button.setVisibility(View.GONE);
			 * before_fanhui.setVisibility(View.VISIBLE);
			 */

			switch (v.getId()) {
			case R.id.after_landing_index:
				if (add_in == 5) {
					if (indexbutton.isSelected() == true) {
						indexbutton.setSelected(false);
						afterLandingMyHomePageZhanleiXinFragment
								.setOnIndexClistener(new IndexButtonState() {
									@Override
									public boolean indexButtonSelect(
											boolean isSelectIndexBtn) {
										return isSelectIndexBtn = false;
									}
								});
					} else {
						indexbutton.setSelected(true);

						afterLandingMyHomePageZhanleiXinFragment
								.setOnIndexClistener(new IndexButtonState() {

									@Override
									public boolean indexButtonSelect(
											boolean isSelectIndexBtn) {
										return true;
									}
								});
						// 更新适配器

					}

				} else if (indexbutton.isSelected() == false) {
					intent = new Intent(AfterLandingActivity.this,
							IndexActivity.class);
				} else if (indexbutton.isSelected() == true) {
					String[] items = new String[] {
							getResources().getString(R.string.TheEditor),
							getResources().getString(R.string.Add) };
					MyDiaglogInterface d = new MyDiaglogInterface(
							AfterLandingActivity.this);
					d.singleChoice(items);
					d.setOnMyDiaglogInterClickListener(new OnMyDiaglogInterClickListener() {

						@Override
						public void ok(int itemNum) {
							if (itemNum == 0) {
								intent = new Intent(AfterLandingActivity.this,
										GroupManagementActivity.class);

							} else if (itemNum == 1) {
								intent = new Intent(AfterLandingActivity.this,
										AddFriendsActivity.class);
							}
							if (intent != null) {
								startActivity(intent);
								intent = null;
							}
						}

						@Override
						public void cancle(int itemNum) {
						}
					});

				}
				break;

			case R.id.before_fanhui:
				Utils.showMessage(AfterLandingActivity.this, getResources()
						.getString(R.string.l_xb10));
				finish();

				// before_fanhui.setVisibility(View.GONE);
				// closedraw_button.setVisibility(View.VISIBLE);
				break;

			}
			if (intent != null) {
				startActivity(intent);
				intent = null;
			}

		}
	}

	/** 打开或者关闭slidingMenu菜单 */
	public void OpenOrCloseSlidingMenu() {
		if (slideMenu.isMainScreenShowing()) {
			slideMenu.openMenu();
		} else {
			slideMenu.closeMenu();
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode,
			final Intent data) {
		if (resultCode == INTENT_RESULT && data != null) {

		}
		super.onActivityResult(requestCode, resultCode, data);

	}

	public void club_options() {

		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {
				if (afterLandingMyHomePageClubManangerFragment != null) {
					while (isRun) {
						afterLandingMyHomePageClubManangerFragment
								.getPersonalCenterHomePageModel(new AfterLandingMyHomePageClubManangerFragment.Callback() {

									@Override
									public void getPersonalCenterHomePageModel2(
											PersonalCenterHomePageModel per) {
										if (per != null) {
											personalCenterHomePageModel2 = per;
											isRun = false;
										}
									}
								});
					}

				}
			}
		});

		// 俱乐部发动态
		this.findViewById(R.id.clubfadongtai).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						if (!Utils.getUid(AfterLandingActivity.this).equals("")) {

							if (personalCenterHomePageModel2 != null) {
								if (afterLandingMyHomePageClubManangerFragment != null
										&& !afterLandingMyHomePageClubManangerFragment
												.getClub_type().equals("3")) {
									Intent intent = new Intent(
											AfterLandingActivity.this,
											Club_SendDynamicActivity.class);
									intent.putExtra("cid", cid);
									intent.putExtra("head", logo);
									startActivity(intent);
									finish();
								} else {
									// Toast.makeText(getApplicationContext(),
									// "请加入俱乐部", 0).show();
									builder = new Builder(
											AfterLandingActivity.this).setView(
											Back_Buju(0)).show();
								}
							}
						} else {
							Utils.showMessage(AfterLandingActivity.this,
									getResources().getString(R.string.l_xb10));
						}

					}
				});

		// 俱乐部发活动
		this.findViewById(R.id.club_activity).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						if (!Utils.getUid(AfterLandingActivity.this).equals("")) {
							if (personalCenterHomePageModel2 != null) {
								if (afterLandingMyHomePageClubManangerFragment != null
										&& !afterLandingMyHomePageClubManangerFragment
												.getClub_type().equals("3")
										&& personalCenterHomePageModel2 != null) {
									Constants.is_shuaxin = true;
									Intent intent = new Intent(
											AfterLandingActivity.this,
											PostActivity1Activity.class);
									intent.putExtra("cid", cid);
									startActivity(intent);
								} else {
									// Toast.makeText(getApplicationContext(),
									// "请加入俱乐部", 0).show();
									builder = new Builder(
											AfterLandingActivity.this).setView(
											Back_Buju(1)).show();
								}
							}
						} else {
							Utils.showMessage(AfterLandingActivity.this,
									getResources().getString(R.string.l_xb10));
						}

					}
				});
	}

	/**
	 * 
	 * @param c
	 *            0动态，其他的是活动
	 * @return
	 */
	private View Back_Buju(int c) { // infos
		View view = null;
		LayoutInflater inflater = LayoutInflater
				.from(AfterLandingActivity.this);
		view = inflater.inflate(R.layout.recordlistclub_is_add_club, null);
		Button record_linear_add_club = (Button) view
				.findViewById(R.id.record_linear_add_club);
		Button record_linear_quxiao = (Button) view
				.findViewById(R.id.record_linear_quxiao);

		TextView infos = (TextView) view.findViewById(R.id.infos);
		if (c == 0) {
			infos.setText(getResources().getString(R.string.wx2_3));
		} else {
			infos.setText(getResources().getString(R.string.l_xb2));
		}

		record_linear_add_club.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				if (Integer.parseInt(personalCenterHomePageModel2.getGold()) >= Integer
						.parseInt(personalCenterHomePageModel2.getPrice())) {
					

					if (personalCenterHomePageModel2.getIs_apply().equals("0")) {
						Add_club("0", "");
					} else {
						Intent intent = new Intent(AfterLandingActivity.this,
								AddApplyFormActivity.class);
						intent.putExtra("pan", "set");
						intent.putExtra("cid", cid);
						startActivity(intent);
					}
				}else {
					Utils.showMessage(AfterLandingActivity.this,
							getResources().getString(R.string.wx_txt_111));
				}

				builder.dismiss();
			}
		});
		record_linear_quxiao.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				builder.dismiss();
			}
		});
		return view;
	}

	private void Add_club(final String is_apply, final String content) {
		Utils.showPrgress(AfterLandingActivity.this);
		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", Utils.getUid(AfterLandingActivity.this));
				map.put("cid", cid);
				map.put("is_apply", is_apply);
				if (is_apply.equals("1")) {
					map.put("contents", content);
				}
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "club/attendClub");
				if (content != null) {
					resultsdd = Utils.checkResult_NNN(getApplicationContext(),
							content);
					if (resultsdd != null
							&& !resultsdd.getRetmsg().equals("null")) {
						handler.sendEmptyMessage(8);
					} else {
						handler.sendEmptyMessage(9);
					}
				} else {
					handler.sendEmptyMessage(10);
				}
			}
		});
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (isStartTwoClose == false && keyCode == KeyEvent.KEYCODE_BACK
				&& event.getAction() == KeyEvent.ACTION_DOWN) {

			isStartTwoClose = true;
			return super.onKeyDown(keyCode, event);
		} else if (keyCode == KeyEvent.KEYCODE_BACK
				&& event.getAction() == KeyEvent.ACTION_DOWN) {
			if ((System.currentTimeMillis() - exitTime) > 2000) {
				Toast.makeText(getApplicationContext(),
						getResources().getString(R.string.l_xb3),
						Toast.LENGTH_SHORT).show();
				exitTime = System.currentTimeMillis();
			} else {
				exit();
			}
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	}

	/***
	 * 刷新个人主页
	 */
	public void resh9() {
		FragmentTransaction myTransaction = myManager.beginTransaction();
		afterLandingMyHomePageMyFragment = new AfterLandingMyHomePageMyFragment()
				.getInstance();
		Bundle bun = new Bundle();
		bun.putBoolean("enterCollect", enterCollect);
		afterLandingMyHomePageMyFragment.setArguments(bun);
		myTransaction.replace(R.id.after_landing_layout,
				afterLandingMyHomePageMyFragment);
		myTransaction.commit();
		add_in = 9;
		enterCollect = false;
	}

	/**
	 * 0 获取IndexButton选中情况
	 * 
	 * @return
	 */
	public boolean getIndexButtonSelect() {
		return indexbutton.isSelected();
	}

	public int getAdd_in() {
		return add_in;
	}

	public void setAdd_in(int add_in) {
		this.add_in = add_in;
	}

}
